package org.example.work.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.work.mapper.CategoryMapper;
import org.example.work.pojo.Category;
import org.example.work.service.CategoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现类
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>
    implements CategoryService {

    @Override
    public void addCategory(Category category) {
        if(category==null){
            return;
        }
        save(category);
    }

    @Override
    public Category getCategoryById(Integer id) {
        if(id==null){
            return null;
        }
        return getById(id);
    }

    @Override
    public List<Category> getCategoryList() {
        return list();
    }

    @Override
    public void updateCategory(Category category) {
        updateById(category);
    }

    @Override
    public void deleteCategory(Integer id) {
        removeById(id);
    }
}




